﻿<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="content-language" lang="zh-cn">
    <title>问卷系统登录</title>
    <link href="~/Content/bootstrap2.css" rel="stylesheet" />
    <style>
        body {
            color: white;
        }

        .main-position {
            width: 60%;
            margin: 150px auto;
        }

            .main-position .control-group {
                margin-left: 50px;
            }
    </style>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
</head>
<body>
    <div class="container">
        <div class="main-position">
            @using (Html.BeginForm("Register", "Auth", FormMethod.Post, new { @class = "form_horizontal", Ares = "UserOP", id="registerform" }))
            {
                <fieldset>
                    <legend>
                        <img src="~/images/logo_blue.png"/>
                        <span style="color:#0088cc;">注册</span>
                    </legend>
                    <p style="color:red" id="Msg">@ViewBag.Msg</p>
                    <div class="control-group">
                        <input type="text" name="name" placeholder="登录名" class="span4" style="height: 30px;line-height:30px;" />
                    </div>
                    <div class="control-group">
                        <input type="text" name="email" placeholder="登录邮箱" class="span4" style="height: 30px;line-height:30px;" />
                    </div>
                    <div class="control-group">
                        <input type="text" name="phone" placeholder="联系电话" class="span4" style="height: 30px;line-height:30px;" />
                    </div>
                    <div class="control-group">
                        <input type="password" name="password" placeholder="密码" class="span4" style="height: 30px;line-height:30px;" />
                    </div>
                    <div class="control-group">
                        <input type="password" name="confirmpassword" placeholder="确认密码" class="span4" style="height: 30px;line-height:30px;" />
                    </div>
                    <div class="control-group">
                        <button type="submit" class="btn btn-primary span2" style="margin-left: 0px;">注册</button>
                        <p>
                            <span style="color:#0088cc;line-height:50%; margin-left:80px;margin-top:10px !important;"><a href="~/Userop/Auth/Login"> 返回登录 </a></span>
                        </p>
                    </div>
                </fieldset>
            }
        </div>
    </div>
    <script>
        var regBox = {
            regEmail: /^([a-z0-9_\.-]+)@@([\da-z\.-]+)\.([a-z\.]{2,6})$/,      //邮箱
            regMobile: /^0?1[3|4|5|8][0-9]\d{8}$/,                            //手机
        }

        $("#registerform").submit(function () {
            var name = $("input[name='name']").val();
            var email = $("input[name='email']").val();
            var phone = $("input[name='phone']").val();
            var password = $("input[name='password']").val();
            var confirmpassword = $("input[name='confirmpassword']").val();
            //1. 为空检测
            if (name == "" || typeof (name) == 'undefined')
            {
                $("#Msg").text("用户名不能为空");
                $("input[name='name']").focus();
                return false;
            }
            else if (email == "" || typeof (email) == 'undefined')
            {
                $("#Msg").text("登录邮箱不能为空");
                $("input[name='email']").focus();
                return false;
            }
            else if (phone == "" || typeof (phone) == 'undefined') {
                $("#Msg").text("手机号不能为空");
                $("input[name='phone']").focus();
                return false;
            }
            else if (password == "" || typeof (password) == 'undefined') {
                $("#Msg").text("密码不能为空");
                $("input[name='password']").focus();
                return false;
            }

            //2. 格式检测
            if (!regBox.regEmail.test(email))
            {
                $("#Msg").text("邮箱格式错误");
                $("input[name='email']").focus();
                return false;
            }
            if (!regBox.regMobile.test(phone))
            {
                $("#Msg").text("手机号格式错误");
                $("input[name='phone']").focus();
                return false;
            }

            //3. 密码检测
            if (password != confirmpassword)
            {
                $("#Msg").text("两次密码不一致");
                $("input[name='password']").focus();
                return false;
            }

        });
    </script>
</body>
</html>

